define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user/rank/index',
                    table: 'user_rank',
                }
            });

            var table = $("#table_rank");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'score',
                columns: [
                    [
                    	
                    	{field: 'score', formatter: function (score, row, index) {
 							return index+1;
 						},title: __('排名')},
                        {field: 'score', title: __('积分')},
                        {field: 'id', title: __('Id'), visible: false},
                        {field: 'avatar', title: __('头像'), formatter: Table.api.formatter.image, operate: false},
                        {field: 'username', title: __('Username')},
                        {field: 'nickname', title: __('Nickname')},
                        {field: 'group.name', title: __('Group'), visible: false},
                        {field: 'email', title: __('Email')},
                        {field: 'mobile', title: __('Mobile')},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
